How to send mail using Gmail in ASP.Net with Godaddy Server?
Cannot send email in ASP.Net through GoDaddy Servers?
In ASP.Net we can sennd mail to anyone using gmail smtp server. We have created codes for sending mail using gmail credentials and it is working fine in local. But when we uploaded to the server we are unable to send mail using the options. The thing is that we are using GoDaddy Server as hosting server and it is not supported the gmail smtp server to send mail.
How to Send mail in ASP.Net with GoDaddy Server
Inorder to send mail using ASP.Net we got a support from godaddy department and now it is working fine. Following are the codes for sending mail in ASP.Net with GoDaddy Server:
using System.Web.Mail; public static void sendEmail(EmailDetails objEmail) { try { string SERVER = ConfigurationSettings.AppSettings["MailServer"].ToString(); MailMessage oMail = new System.Web.Mail.MailMessage(); oMail.From = objEmail.From; oMail.To = objEmail.To; oMail.Cc = ConfigurationSettings.AppSettings["AdminEmailID"].ToString(); oMail.Subject = objEmail.Subject; oMail.BodyFormat = MailFormat.Html; // enumeration oMail.Priority = MailPriority.High; // enumeration oMail.Body = objEmail.Message; SmtpMail.SmtpServer = SERVER; SmtpMail.Send(oMail); oMail = null; // free up resources } catch (Exception ex) { throw; } }
Here we have a object ‘objEmail’ which holds the mail details such as from address, to address, subject etc. We have to use System.Web.Mail class for send mail. Here we are taking server details from web.config as given below.
<add key="MailServer" value="mail.gmail.com" />
When we are running in local system the above code is working fine, but when we uploaded to goDaddy server send mail is not working. Then we have to change mail server details in web.config to following one.
<add key="MailServer" value="relay-hosting.secureserver.net" />
thank you, It solve my problem
You are welcome! Please keep visit blog 🙂
sorry these code not running on server.it run successfully on local.
what step we done in go daddy any setting .
sorry these code not running on server.it run successfully on local.
what step we done in go daddy any setting .
You need to change mail server name when you upload to the server to ‘relay-hosting.secureserver.net’
mail is running in local perfectly but we run on server it doesn’t run
we allready change local server name…(:
code below
System.Net.Mail.MailMessage Mail = new MailMessage();
Mail.From = new MailAddress(“sales@socailizedit.com”);
if (ur.email.ToString() != “”)
{
Mail.Subject = Convert.ToString(“Query Sucessfully Registered”);
Mail.To.Add(ur.email.ToString());
//Mail.From = “vesturesupport01@vestureindia.com”;
//string server = “relay-hosting.secureserver.net”;
//string server = “smtp.gmail.com”;
//Mail.To = ur.Email.ToString();
//Mail.Cc = “ravi@vestureindia.com”;
//Mail.Priority = System.Web.Mail.MailPriority.High;
//Mail.BodyFormat = MailFormat.Html;
//Mail.Body = strbuld.ToString();
//SmtpMail.SmtpServer = server;
//SmtpMail.Send(Mail);
//Mail.Cc = “ravi@vestureindia.com”;
Mail.IsBodyHtml = true;
Mail.Body = strbuld.ToString();
System.Net.Mail.SmtpClient smtp = new SmtpClient();
smtp.Port = 587;
smtp.Host = “smtp.gmail.com”;
smtp.Credentials = new System.Net.NetworkCredential(“sales@socializedit.com”, “sales@123”);
smtp.EnableSsl = true;
smtp.Send(Mail);
}
strbuld.Remove(0, strbuld.Length);
Mail = null;
Hi Surinder,
In the above mentioned code, you specified smtp server as gmail. You need to change once you upload to server as I mentioned in the post.
relay-hosting.secureserver.net
Please try and let me know if you face any further issue
Normally I don’t read article on blogs, however I would like to say that this write-up very forced me to check out and do it! Your writing style has been amazed me. Thank you, quite nice post.
I tend not to create a bunch of remarks, but i did a few searching and wound up here How to send mail using
Gmail in ASP.Net with Godaddy Server? | Tuvian :
Discussion forum for ASP.Net,C#,Ajax,JQuery,JavaScript,HTML,CSS.
.. And I actually do have a couple of questions for you if it’s allright. Is it just me or does it look as if like a few of the comments come across like they are left by brain dead individuals? 😛 And, if you are writing at additional social sites, I would like to keep up with anything fresh you have to post. Could you make a list of all of your communal pages like your linkedin profile, Facebook page or twitter feed?
Hi SharecashHack,
Thanks for visiting our blog..
Our Official site is http://www.tuvian.com
hi my mail sending code is not working can u help me
the hosting goddady ..in local it’s working .i change the relay-hosting.secureserver.net for sever said but it’s not working what can i do…
Hi Vinathi,
Can you please post your codes so that I can find issues and fix.
Thanks